package com.alan.mongodb.elasticsearch;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @Author Alan liu
 * @Date 18:16 2018/11/23
 * @return
 **/
//@Configuration
public class ElasticSearchConfiguration {
    @Value("${elasticsearch.clusterName}")
    private String clusterName;

    @Value("${elasticsearch.clusterServers}")
    private String[] clusterServers;

    @Value("${elasticsearch.host}")
    private String host;

    @Value("${elasticsearch.port}")
    private int port;

    @Bean
    public TransportClientFactory transportClient(){
        TransportClientFactory transportClientFactory=new TransportClientFactory();
        transportClientFactory.setClusterName(clusterName);
        transportClientFactory.setClusterServers(clusterServers);
        transportClientFactory.setHost(host);
        transportClientFactory.setPort(port);
        return transportClientFactory;
    }

}
